package com.rh.gtoa.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class Config {
    @Autowired
    private UserInterceptor userInterceptor;

    /**
     * 拦截器
     * */
    @Bean
    public WebMvcConfigurer WebMvcConfigurer() {
        return new WebMvcConfigurer() {
            public void addInterceptors(InterceptorRegistry registry) {
                //排除无需拦截路径
                List<String> l=new ArrayList<>();
                l.add("/ums/umsUser/login");
                l.add("/nkbUser/nKaddNkbUser");
                l.add("/swagger-ui.html#/**");
                //配置需要拦截路径/*.do
                registry.addInterceptor(userInterceptor)
                        .addPathPatterns("/ecn/**")
                        .addPathPatterns("/ema/**")
                        .addPathPatterns("/exe/**")
                        .addPathPatterns("/fai/**")
                        .addPathPatterns("/ite/**")
                        .addPathPatterns("/pdt/**")
                        .addPathPatterns("/tas/**")
                        .addPathPatterns("/tim/**")
                        .addPathPatterns("/typ/**")
                        .addPathPatterns("/ums/**")
                        .addPathPatterns("/ver/**")
                        .excludePathPatterns(l);
            }
        };
    }

}
